1. Field of the Invention
This invention relates generally to the field of computer graphics and, more particularly, to a system and method for rendering scenes including the effects of shadowing with respect to one or more light sources.
2. Description of the Related Art
Shadow mapping is a technique for generating shadows on three-dimensional graphics hardware. It involves computing a first image (i.e., the shadow depth image) from the point of view of a light source that is to cast shadows. Each pixel in the first image indicates a distance between the light source and an object visible along a ray emanating from the light source. The scene is then re-rendered from the viewer's location to generate a second image (i.e., the rendered image) as follows. At each visible point P of an object its distance DP to the light source is computed. If the distance between the object point and the light source is less than or equal to the distance of the closest object to the light source along the same directional ray, the object point is illuminated. If not, the object point is in shadow. Standard matrix transformations may be used to compute the required distances and to identify the point in the shadow depth image that corresponds with a screen pixel in the rendered image. This technique is prone to jagged shadow edges, since each pixel is determined to be entirely in or out of shadow.
In order to smooth the shadow edges, a neighborhood of several pixels is examined in the shadow depth image, and the distance of each pixel in the neighborhood is compared to the object-light distance DP. The proportion of nearby shadow pixels that are smaller than the object-light distance DP is used to determine the degree of shadow. This is known in the literature as “percentage closer” filtering. Rather than simply counting how many pixels are closer, which may lead to stairstep artifacts, it is conventional to apply a set of weights to each shadow pixel in the neighborhood, so that more central shadow pixels are given greater influence in the result.
Because filtered shadow mapping improves the appearance of rendered shadows, it would be very desirable to provide support for this feature in graphics rendering hardware, especially in real-time graphics rendering hardware.